package com.qdlc.p2p.biz.executer;

import com.qdlc.p2p.biz.service.AccountService;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.constant.LogTemplateType;
import com.qdlc.p2p.common.util.BeanUtil;
import com.qdlc.p2p.common.util.FreemarkerUtil;
import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.common.LogTemplateHelper;
import com.qdlc.p2p.dal.dao.AccountBankDao;
import com.qdlc.p2p.dal.dao.AccountCashDao;
import com.qdlc.p2p.dal.dao.AccountDao;
import com.qdlc.p2p.dal.dao.AccountLogDao;
import com.qdlc.p2p.dal.dao.OperationLogDao;
import com.qdlc.p2p.dal.dao.UserCacheDao;

/**
 * 执行器基础类
 *
 * @author Kaiju Zhao
 * @date 2016-03-17
 * @version 1.1.0.0
 */
public class BaseExecuter extends AbstractExecuter {

	protected AccountDao accountDao;
	protected AccountLogDao accountLogDao;
	protected OperationLogDao operationLogDao;
	protected UserCacheDao userCacheDao;
	protected AccountCashDao accountCashDao;
	protected AccountBankDao accountBankDao;
	protected AccountService accountService;

	@Override
	public void prepare() {
		accountLogDao = (AccountLogDao) BeanUtil.getBean("accountLogDao");
		accountDao = (AccountDao) BeanUtil.getBean("accountDao");
		operationLogDao = (OperationLogDao) BeanUtil.getBean("operationLogDao");
		userCacheDao = (UserCacheDao) BeanUtil.getBean("userCacheDao");
		accountCashDao = (AccountCashDao) BeanUtil.getBean("accountCashDao");
		accountBankDao = (AccountBankDao) BeanUtil.getBean("accountBankDao");

		accountService = (AccountService) BeanUtil.getBean("accountService");
	}

	@Override
	public void addAccountLog() {

	}

	@Override
	public void handleAccountWithLog() {

	}

	@Override
	public void handleNotice() {

	}
	
	@Override
	public void addOperateLog() {

	}

	@Override
	public void extend() {

	}

	/**
	 * 获取日志模板类型
	 *
	 * @author Kaiju Zhao
	 */
	public String getAccountLogType() {
		return null;
	}

	/**
	 * 根据日志类型获取到备注模板信息
	 *
	 * @author Kaiju Zhao
	 */
	public String getLogRemark() {
		String template = LogTemplateHelper.getValue(LogTemplateType.ACCOUNT_LOG, getAccountLogType());
		try {
			if (StringUtil.isNotBlank(template)) {
				return FreemarkerUtil.renderTemplate(template, Global.getTransfer());
			}
		} catch (Exception e) {
		}
		return "";
	}
}
